#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int n,m,i,j,s[105][105];
int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            cin>>a[i][j];
            if(a[i][j]=='*'){
            s[i][j+1]++;
            s[i][j-1]++;
            s[i+1][j]++;
            s[i-1][j]++;
            s[i+1][j+1]++;
            s[i+1][j-1]++;
            s[i-1][j-1]++;
            s[i-1][j+1]++;
            }
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(a[i][j]=='*'){
                cout<<"*";
            }
            else{
                cout<<s[i][j];
            }
        }
        cout<<endl;
    }
    return 0;
}

